<div class="main-content">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <ol class="breadcrumb">
                    <li>
                        <i class="clip-file"></i>
                        <a href="#">
                            Logística
                        </a>
                    </li>
                    <li class="active">
                        Tablas Maestras
                    </li>					
                </ol>
                <div class="page-header">
                    <h1>Tablas Maestras <small>Línea | Familia | Marca | Sucursal | Almacén </small></h1>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="tabbable">
                    <ul id="myTab" class="nav nav-tabs tab-bricky">
                        <li class="active">
                            <a href="#panel_tab2_example1" id="tabLinea" data-toggle="tab">
                                <i class="green icon-cog"></i> Línea
                            </a>
                        </li>
                        <li>
                            <a href="#panel_tab2_example2" id="tabFam" data-toggle="tab">
                                <i class="green icon-cog"></i> Familia
                            </a>
                        </li>
                        <li>
                            <a href="#panel_tab2_example3" id="tabMarca" data-toggle="tab">
                                <i class="green icon-cog"></i> Marca
                            </a>
                        </li>
                        <li>
                            <a href="#panel_tab2_example4" id="tabSuc" data-toggle="tab">
                                <i class="green icon-cog"></i> Sucursal
                            </a>
                        </li>
                        <li>
                            <a href="#panel_tab2_example5" id="tabAlm" data-toggle="tab">
                                <i class="green icon-cog"></i> Almacén
                            </a>
                        </li>                        

                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane in active" id="panel_tab2_example1">
                            <p>
                                <a id="abrirFrmLinea" class='btn btn-primary tooltips panel-config' data-placement='left' data-toggle="modal" href="#formularioLog" data-original-title='Nueva Línea'><i class='icon-plus'></i> Agregar</a>
                            </p>
                            <div class="panel-scroll">
                                <table class="table table-striped table-bordered table-condensed table-hover table-full-width" id="tblLinea">
                                    <thead>
                                        <tr>
                                            <th>Línea</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="tab-pane" id="panel_tab2_example2">
                            <p>
                                <a id="abrirFrmFam" class='btn btn-primary tooltips  panel-config' data-placement='left' data-toggle="modal" href="#formularioLog" data-original-title='Nueva Familia'><i class='icon-plus'></i> Agregar</a>
                            </p>                            
                            <div class="panel-scroll">
                                <table class="table table-striped table-condensed table-bordered table-hover" id="tblFamilia">
                                    <thead>
                                        <tr>
                                            <th>Familia</th>
                                            <th>Línea</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="tab-pane" id="panel_tab2_example3">
                            <p>
                                <a id="abrirFrmMarca" class='btn btn-primary tooltips  panel-config' data-placement='left' data-toggle="modal" href="#formularioLog" data-original-title='Nueva Marca'><i class='icon-plus'></i> Agregar</a>
                            </p>
                            <div class="panel-scroll">
                                <table class="table table-striped table-bordered table-condensed table-hover table-full-width" id="tblMarca">
                                    <thead>
                                        <tr>
                                            <th>Marca</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="tab-pane" id="panel_tab2_example4">
                            <p>
                                <a id="abrirFrmSuc" class='btn btn-primary tooltips  panel-config' data-placement='left' data-toggle="modal" href="#formularioLog" data-original-title='Nueva Sucursal'><i class='icon-plus'></i> Agregar</a>
                            </p>
                            <div class="panel-scroll">
                                <table class="table table-striped table-bordered table-condensed table-hover table-full-width" id="tblSucursal">
                                    <thead>
                                        <tr>
                                            <th>Sucursal</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="tab-pane" id="panel_tab2_example5">
                            <p>
                                <a id="abrirFrmAlmacen" class='btn btn-primary tooltips  panel-config' data-placement='left' data-toggle="modal" href="#formularioLog" data-original-title='Nuevo Almacén'><i class='icon-plus'></i> Agregar</a>
                            </p>
                            <div class="panel-scroll">
                                <table class="table table-striped table-bordered table-condensed table-hover table-full-width" id="tblAlmacen">
                                    <thead>
                                        <tr>
                                            <th>Almacén</th>
                                            <th>Sucursal</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>                        
                    </div>
                </div>
            </div>            
        </div>
    </div>
</div>


<div id="formularioLog" class="modal fade" aria-hidden="true" role="dialog" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" aria-hidden="true" data-dismiss="modal" type="button">
                    ×
                </button>
                <h4 class="modal-title" id="tituFrm">
                    
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <!-- start: TEXT FIELDS PANEL -->

                        <div class="panel-body">
                            <form role="form" class="form-horizontal">
                                <input type="hidden" id="txttipo" class="form-control">
                                <input type="hidden" id="txtcod" class="form-control" value="0">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" for="txtdesc">
                                        Descripción
                                    </label>
                                    <div class="col-sm-9">                                        
                                        <input type="text" id="txtdesc" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group" id="divTipo">
                                    <label class="col-sm-2 control-label" for="form-field-21">
                                        Línea
                                    </label>
                                    <div class="col-sm-9">
                                        <select id="cbotipo" class="form-control search-select">
                                            <option></option>
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>

                        <!-- end: TEXT FIELDS PANEL -->
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" id="cerrarFormMarca" data-dismiss="modal" type="button">
                    Cerrar
                </button>
                <button class="btn btn-primary" type="button" id="guardar" > 
                    Guardar
                </button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function() {
        //$('#tblLinea,#tblFamilia,#tblMarca').dataTable();
        
        $("#txttipo").val('linea');
        tablasMaestrasLog('<?php echo base_url("logistica/tablasmaestra/listTMLogistica/linea/0") ?>', 'linea', 'tblLinea');
        $("#tabLinea").click(function() {
            $("#txttipo").val('linea');
            tablasMaestrasLog('<?php echo base_url("logistica/tablasmaestra/listTMLogistica/linea/0") ?>', 'linea', 'tblLinea');
        });
        $("#tabFam").click(function() {
            $("#txttipo").val('familia');
            tablasMaestrasLog('<?php echo base_url("logistica/tablasmaestra/listTMLogistica/familia/0") ?>', 'familia', 'tblFamilia');
            $("#cbotipo option").remove();
            combo("<?php echo base_url("logistica/proceso/combo/linea/0") ?>", "cbotipo");
        });
        $("#tabMarca").click(function() {
            $("#txttipo").val('marca');
            tablasMaestrasLog('<?php echo base_url("logistica/tablasmaestra/listTMLogistica/marca/0") ?>', 'marca', 'tblMarca');
        });
        $("#tabSuc").click(function() {
            $("#txttipo").val('sucursal');
            tablasMaestrasLog("<?php echo base_url("logistica/tablasmaestra/listTMLogistica/sucursal/0") ?>", "sucursal", "tblSucursal");
        });
        $("#tabAlm").click(function() {
            $("#txttipo").val('almacen');
            tablasMaestrasLog('<?php echo base_url("logistica/tablasmaestra/listTMLogistica/almacen/0") ?>', 'almacen', 'tblAlmacen');
            $("#cbotipo option").remove();
            combo("<?php echo base_url("logistica/proceso/combo/sucursal/0") ?>", "cbotipo");
        });

        $("#abrirFrmLinea").click(function() {propiedadesFrm("", "Línea"); $("#txtdesc").val(""); $("#txtcod").val(""); removepropclose("guardar");});
        $("#abrirFrmMarca").click(function() {propiedadesFrm("", "Marca"); $("#txtdesc").val(""); $("#txtcod").val(""); removepropclose("guardar");});
        $("#abrirFrmSuc").click(function() {propiedadesFrm("", "Sucursal"); $("#txtdesc").val(""); $("#txtcod").val(""); removepropclose("guardar");});

        $("#abrirFrmFam").click(function() {
            propiedadesFrm("Línea", "Familia"); $("#txtdesc").val(""); $("#txtcod").val("");
            removepropclose("guardar");
        });

        $("#abrirFrmAlmacen").click(function() {
            propiedadesFrm("Sucursal", "Almacén"); $("#txtdesc").val(""); $("#txtcod").val("");
            removepropclose("guardar");
        });

        $("#guardar").click(function() {
            InUp_LogTM('<?php echo base_url("logistica/tablasmaestra/InUp_LogTM") ?>');
        });
    });
    
    function removepropclose(id){
        $("#"+id).removeAttr("data-dismiss","modal");
    }
    
</script>